import { ref } from "vue";
import { useRouter } from "vue-router";
const useTabsState = () => {
  const isActive = ref<any>(0);
  const router = useRouter(); //路由实例
  const toTargetRoute = (routeName: string, id?: string) => {
    //跳转路由函数
    switch (routeName) {
      case "Recommend":
        router.push({ name: "Recommend" });
        isActive.value = 0;
        break;
      case "Original":
        router.push({ name: "Original" });
        isActive.value = 1;
        break;
      case "Course":
        router.push({ name: "Course" });
        isActive.value = 2;
        break;
      case "SpecialTopic":
        router.push({ name: "SpecialTopic" });
        isActive.value = 3;
        break;
      case "Information":
        router.push({ name: "Information" });
        isActive.value = 4;
        break;
      case "Attention":
        router.push({ name: "Attention" });
        isActive.value = 5;
        break;
      default:
        router.push({
          name: "Index",
          params: {
            targetId: id,
          },
        });
        isActive.value = id;
    }
  };
  /*----------------------------  暴露数据  ---------------------------------*/
  return { isActive,toTargetRoute };
};
export default useTabsState;
